package com.yang.demo;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jaeger.library.StatusBarUtil;
import com.yang.demo.activity.ReportActivity;
import com.yang.demo.util.image.LoadImageCtrl;
import com.yang.demo.util.rxbus.RxBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by mc on 2018/3/23.
 * <p>
 * 作品详情展示页
 */

public class DetailsActivity extends AppCompatActivity {

    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.iamge)
    ImageView iamge;
    @BindView(R.id.piantou)
    TextView piantou;
    @BindView(R.id.daoyan)
    TextView daoyan;
    @BindView(R.id.pinfeng)
    TextView pinfeng;
    @BindView(R.id.shijian)
    TextView shijian;
    @BindView(R.id.zhuti)
    TextView zhuti;
    @BindView(R.id.ll_jianjie)
    LinearLayout llJianjie;
    @BindView(R.id.jianjie)
    TextView jianjie;
    private String strpiantou;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);
        ButterKnife.bind(this);
        LoadImageCtrl loadImageCtrl = new LoadImageCtrl(this);
        StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.main_blue), 50);
        StatusBarUtil.setLightMode(this);

        //读取作品详情
        Intent intent = getIntent();
        String strimage = intent.getStringExtra("image");
        strpiantou = intent.getStringExtra("piantou");
        String strdaoyan = intent.getStringExtra("daoyan");
        String strpinfen = intent.getStringExtra("pinfen");
        String strshijian = intent.getStringExtra("shijian");
        String strtheme = intent.getStringExtra("theme");
        String strjianjie = intent.getStringExtra("jianjie");


        //显示数据
        piantou.setText("片名：" + strpiantou);
        daoyan.setText("导演：" + strdaoyan);
        pinfeng.setText("评分：" + strpinfen);
        shijian.setText("上映时间：" + strshijian);
        zhuti.setText("主题：" + strtheme);
        jianjie.setText(strjianjie);
        loadImageCtrl
                .getGlide()
                .load(strimage)
                .crossFade()
                .centerCrop()
                .into(iamge);


    }

    @OnClick({R.id.tv_no, R.id.tv_yes})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_no:
                finish();
                break;
            case R.id.tv_yes:
                //生成报告
                Constant.MOVIE = strpiantou;
                startActivity(new Intent(this, ReportActivity.class));
                finish();
                break;
            default:
                break;
        }
    }
}
